package view.systemAdmiView;

import java.awt.EventQueue;

import javax.swing.JInternalFrame;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import java.awt.Color;
import java.awt.Font;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;

import dao.BookDao;
import dao.BookTypeDao;
import model.Book;
import model.BookType;
import util.DbUtil;

import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.Vector;
import java.awt.event.ActionEvent;
import javax.swing.JScrollPane;
import javax.swing.JTable;

public class BookSearchInterFrm extends JInternalFrame {
	private JTextField s_bookNameTxt;
	private JTextField s_authorTxt;
	private final ButtonGroup buttonGroup = new ButtonGroup();
	private JTextField bookNameTxt;
	private JTextField idTxt;
	private JTextField authorTxt;
	private JTextField sexTxt;
	private JTextField priceTxt;
	private JTextField bookTypeTxt;
	private JTextField statusTxt;
	private JTextField bookDescTxt;
	private JRadioButton s_notBorrowedJrb;
	private JRadioButton s_borrowedJrb ;
	private JComboBox s_bookTypeJcb ;
	
	private DbUtil dbUtil=new DbUtil();
	private BookTypeDao bookTypeDao=new BookTypeDao();
	private BookDao bookDao=new BookDao();
	private JTable bookTable;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					BookSearchInterFrm frame = new BookSearchInterFrm();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public BookSearchInterFrm() {
		getContentPane().setBackground(new Color(230, 230, 250));
		setTitle("图书查询界面");
		setClosable(true);
		setIconifiable(true);
		setBounds(100, 100, 1832, 886);
		
		JPanel bookSearchPanel = new JPanel();
		bookSearchPanel.setBackground(new Color(255, 218, 185));
		bookSearchPanel.setBorder(new TitledBorder(null, "\u8F93\u5165\u67E5\u8BE2\u6761\u4EF6", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		
		JPanel bookPanel = new JPanel();
		bookPanel.setBackground(new Color(255, 218, 185));
		bookPanel.setBorder(new TitledBorder(null, "\u7B26\u5408\u6761\u4EF6\u7684\u56FE\u4E66\u5982\u4E0B", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		
		JScrollPane bookScrollPane = new JScrollPane();
		
		JLabel title = new JLabel("图书信息查询");
		title.setFont(new Font("宋体", Font.BOLD, 40));
		title.setIcon(new ImageIcon(BookSearchInterFrm.class.getResource("/images/systemAdmi/图书查询 (1).png")));
		GroupLayout groupLayout = new GroupLayout(getContentPane());
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addGroup(groupLayout.createSequentialGroup()
							.addContainerGap()
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
								.addComponent(bookPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
								.addComponent(bookSearchPanel, GroupLayout.PREFERRED_SIZE, 843, Short.MAX_VALUE))
							.addPreferredGap(ComponentPlacement.RELATED, 55, Short.MAX_VALUE)
							.addComponent(bookScrollPane, GroupLayout.PREFERRED_SIZE, 890, GroupLayout.PREFERRED_SIZE))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(686)
							.addComponent(title, GroupLayout.PREFERRED_SIZE, 364, GroupLayout.PREFERRED_SIZE)))
					.addContainerGap())
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(18)
					.addComponent(title, GroupLayout.PREFERRED_SIZE, 112, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(bookScrollPane, GroupLayout.PREFERRED_SIZE, 672, GroupLayout.PREFERRED_SIZE)
						.addGroup(groupLayout.createSequentialGroup()
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(bookSearchPanel, GroupLayout.PREFERRED_SIZE, 242, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
							.addComponent(bookPanel, GroupLayout.PREFERRED_SIZE, 409, GroupLayout.PREFERRED_SIZE)))
					.addGap(81))
		);
		
		bookTable = new JTable();
		
		bookTable.setBackground(new Color(255, 218, 185));//设置表格背景颜色
		bookTable.getTableHeader().setFont(new Font("微软雅黑",Font.BOLD,20));//设置表格开头字体
		bookTable.getTableHeader().setBackground(new Color(255, 218, 185));//设置表格开头背景颜色
		bookTable.setFont(new Font("楷体", Font.BOLD, 22));//设置表格内容字体
		bookTable.setForeground(new Color(0,0,0));//设置表格内容字体颜色		
		bookTable.setRowHeight(bookTable.getRowHeight()+20);//设置表格内容的行高
		
		bookTable.addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(MouseEvent met) {
				bookTableMousePressed(met);
				
			}
		});
		
		bookTable.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"\u7F16\u53F7", "\u56FE\u4E66\u540D\u79F0", "\u56FE\u4E66\u4F5C\u8005", "\u4F5C\u8005\u6027\u522B", "\u56FE\u4E66\u4EF7\u683C", "\u56FE\u4E66\u63CF\u8FF0", "\u56FE\u4E66\u7C7B\u522B", "\u501F\u9605\u72B6\u6001"
			}
		) {
			boolean[] columnEditables = new boolean[] {
				false, false, false, false, false, false, false, false
			};
			public boolean isCellEditable(int row, int column) {
				return columnEditables[column];
			}
		});
		bookTable.getColumnModel().getColumn(5).setPreferredWidth(171);
		bookScrollPane.setViewportView(bookTable);
		
		JLabel bookName = new JLabel("图书名称：");
		bookName.setFont(new Font("宋体", Font.BOLD, 25));
		bookName.setIcon(null);
		
		bookNameTxt = new JTextField();
		bookNameTxt.setFont(new Font("宋体", Font.BOLD, 25));
		bookNameTxt.setEditable(false);
		bookNameTxt.setColumns(10);
		
		JLabel id = new JLabel("编   号：");
		id.setFont(new Font("宋体", Font.BOLD, 25));
		id.setIcon(null);
		
		idTxt = new JTextField();
		idTxt.setFont(new Font("宋体", Font.BOLD, 25));
		idTxt.setEditable(false);
		idTxt.setColumns(10);
		
		JLabel author = new JLabel("作者姓名：");
		author.setFont(new Font("宋体", Font.BOLD, 25));
		author.setIcon(null);
		
		authorTxt = new JTextField();
		authorTxt.setFont(new Font("宋体", Font.BOLD, 25));
		authorTxt.setEditable(false);
		authorTxt.setColumns(10);
		
		JLabel sex = new JLabel("作者性别：");
		sex.setFont(new Font("宋体", Font.BOLD, 25));
		sex.setIcon(null);
		
		sexTxt = new JTextField();
		sexTxt.setFont(new Font("宋体", Font.BOLD, 25));
		sexTxt.setEditable(false);
		sexTxt.setColumns(10);
		
		JLabel price = new JLabel("图书价格：");
		price.setFont(new Font("宋体", Font.BOLD, 25));
		price.setIcon(null);
		
		priceTxt = new JTextField();
		priceTxt.setFont(new Font("宋体", Font.BOLD, 25));
		priceTxt.setEditable(false);
		priceTxt.setColumns(10);
		
		JLabel bookType_1 = new JLabel("图书类别：");
		bookType_1.setFont(new Font("宋体", Font.BOLD, 25));
		bookType_1.setIcon(null);
		
		bookTypeTxt = new JTextField();
		bookTypeTxt.setFont(new Font("宋体", Font.BOLD, 25));
		bookTypeTxt.setEditable(false);
		bookTypeTxt.setColumns(10);
		
		JLabel status = new JLabel("借阅情况：");
		status.setFont(new Font("宋体", Font.BOLD, 25));
		status.setIcon(null);
		
		statusTxt = new JTextField();
		statusTxt.setFont(new Font("宋体", Font.BOLD, 25));
		statusTxt.setEditable(false);
		statusTxt.setColumns(10);
		
		JLabel bookDesc = new JLabel("图书简介：");
		bookDesc.setFont(new Font("宋体", Font.BOLD, 25));
		bookDesc.setIcon(null);
		
		bookDescTxt = new JTextField();
		bookDescTxt.setFont(new Font("宋体", Font.BOLD, 25));
		bookDescTxt.setEditable(false);
		bookDescTxt.setColumns(10);
		GroupLayout gl_bookPanel = new GroupLayout(bookPanel);
		gl_bookPanel.setHorizontalGroup(
			gl_bookPanel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_bookPanel.createSequentialGroup()
					.addGroup(gl_bookPanel.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_bookPanel.createSequentialGroup()
							.addGap(25)
							.addGroup(gl_bookPanel.createParallelGroup(Alignment.TRAILING)
								.addComponent(status, Alignment.LEADING)
								.addGroup(gl_bookPanel.createSequentialGroup()
									.addGroup(gl_bookPanel.createParallelGroup(Alignment.TRAILING)
										.addGroup(gl_bookPanel.createSequentialGroup()
											.addComponent(id)
											.addPreferredGap(ComponentPlacement.RELATED))
										.addComponent(sex)
										.addComponent(author))
									.addGroup(gl_bookPanel.createParallelGroup(Alignment.LEADING)
										.addComponent(sexTxt, GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)
										.addComponent(idTxt, GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)
										.addGroup(gl_bookPanel.createSequentialGroup()
											.addPreferredGap(ComponentPlacement.RELATED)
											.addGroup(gl_bookPanel.createParallelGroup(Alignment.LEADING)
												.addComponent(authorTxt, GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)
												.addComponent(statusTxt, GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE))))))
							.addGap(125)
							.addGroup(gl_bookPanel.createParallelGroup(Alignment.TRAILING)
								.addComponent(bookType_1)
								.addComponent(price)
								.addComponent(bookName))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_bookPanel.createParallelGroup(Alignment.LEADING, false)
								.addComponent(bookNameTxt, GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
								.addComponent(priceTxt)
								.addComponent(bookTypeTxt)))
						.addGroup(gl_bookPanel.createSequentialGroup()
							.addContainerGap()
							.addComponent(bookDesc)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(bookDescTxt, GroupLayout.PREFERRED_SIZE, 607, GroupLayout.PREFERRED_SIZE)))
					.addContainerGap())
		);
		gl_bookPanel.setVerticalGroup(
			gl_bookPanel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_bookPanel.createSequentialGroup()
					.addGap(22)
					.addGroup(gl_bookPanel.createParallelGroup(Alignment.BASELINE)
						.addComponent(id)
						.addComponent(idTxt, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
						.addComponent(bookName)
						.addComponent(bookNameTxt, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE))
					.addGap(18)
					.addGroup(gl_bookPanel.createParallelGroup(Alignment.BASELINE)
						.addComponent(sex)
						.addComponent(sexTxt, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
						.addComponent(price)
						.addComponent(priceTxt, GroupLayout.PREFERRED_SIZE, 41, GroupLayout.PREFERRED_SIZE))
					.addGap(35)
					.addGroup(gl_bookPanel.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_bookPanel.createParallelGroup(Alignment.BASELINE)
							.addComponent(authorTxt, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addComponent(bookType_1)
							.addComponent(bookTypeTxt, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE))
						.addComponent(author))
					.addGap(36)
					.addGroup(gl_bookPanel.createParallelGroup(Alignment.BASELINE)
						.addComponent(status)
						.addComponent(statusTxt, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE))
					.addGroup(gl_bookPanel.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_bookPanel.createSequentialGroup()
							.addGap(34)
							.addComponent(bookDesc))
						.addGroup(gl_bookPanel.createSequentialGroup()
							.addGap(26)
							.addComponent(bookDescTxt, GroupLayout.PREFERRED_SIZE, 79, GroupLayout.PREFERRED_SIZE)))
					.addGap(14))
		);
		bookPanel.setLayout(gl_bookPanel);
		
		JLabel s_bookName = new JLabel("图书名称：");
		s_bookName.setFont(new Font("宋体", Font.BOLD, 25));
		s_bookName.setIcon(new ImageIcon(BookSearchInterFrm.class.getResource("/images/book.png")));
		
		s_bookNameTxt = new JTextField();
		s_bookNameTxt.setFont(new Font("宋体", Font.BOLD, 25));
		s_bookNameTxt.setColumns(10);
		
		JLabel s_author = new JLabel("作者姓名：");
		s_author.setFont(new Font("宋体", Font.BOLD, 25));
		s_author.setIcon(new ImageIcon(BookSearchInterFrm.class.getResource("/images/book.png")));
		
		s_authorTxt = new JTextField();
		s_authorTxt.setFont(new Font("宋体", Font.BOLD, 25));
		s_authorTxt.setColumns(10);
		
		JLabel bookType = new JLabel("图书类别：");
		bookType.setFont(new Font("宋体", Font.BOLD, 25));
		bookType.setIcon(new ImageIcon(BookSearchInterFrm.class.getResource("/images/book.png")));
		
		s_bookTypeJcb = new JComboBox();
		s_bookTypeJcb.setFont(new Font("宋体", Font.BOLD, 25));
		
		JLabel s_status = new JLabel("借阅情况：");
		s_status.setFont(new Font("宋体", Font.BOLD, 25));
		s_status.setIcon(new ImageIcon(BookSearchInterFrm.class.getResource("/images/book.png")));
		
		s_notBorrowedJrb = new JRadioButton("在馆");
		s_notBorrowedJrb.setFont(new Font("宋体", Font.BOLD, 25));
		buttonGroup.add(s_notBorrowedJrb);
		s_notBorrowedJrb.setSelected(true);
		
		s_borrowedJrb = new JRadioButton("已借");
		s_borrowedJrb.setFont(new Font("宋体", Font.BOLD, 25));
		buttonGroup.add(s_borrowedJrb);
		
		JButton searchButton = new JButton("查询");
		searchButton.setFont(new Font("宋体", Font.BOLD, 25));
		searchButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				bookSearchActionPerformed(e);
			}
		});
		searchButton.setBackground(new Color(245, 222, 179));
		searchButton.setIcon(new ImageIcon(BookSearchInterFrm.class.getResource("/images/bookAdmi/查询.png")));
		
		JButton cancelButton = new JButton("取消");
		cancelButton.setFont(new Font("宋体", Font.BOLD, 25));
		cancelButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				SearchReserValueActionPerformed(e);
			}
		});
		cancelButton.setBackground(new Color(245, 222, 179));
		cancelButton.setIcon(new ImageIcon(BookSearchInterFrm.class.getResource("/images/bookAdmi/重置.png")));
		GroupLayout gl_bookSearchPanel = new GroupLayout(bookSearchPanel);
		gl_bookSearchPanel.setHorizontalGroup(
			gl_bookSearchPanel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_bookSearchPanel.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_bookSearchPanel.createParallelGroup(Alignment.TRAILING)
						.addGroup(gl_bookSearchPanel.createSequentialGroup()
							.addGroup(gl_bookSearchPanel.createParallelGroup(Alignment.TRAILING)
								.addComponent(s_bookName)
								.addComponent(bookType))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_bookSearchPanel.createParallelGroup(Alignment.LEADING)
								.addComponent(s_bookNameTxt, GroupLayout.PREFERRED_SIZE, 157, GroupLayout.PREFERRED_SIZE)
								.addComponent(s_bookTypeJcb, 0, 157, Short.MAX_VALUE))
							.addPreferredGap(ComponentPlacement.RELATED))
						.addGroup(gl_bookSearchPanel.createSequentialGroup()
							.addComponent(searchButton)
							.addGap(19)))
					.addGroup(gl_bookSearchPanel.createParallelGroup(Alignment.LEADING, false)
						.addGroup(gl_bookSearchPanel.createSequentialGroup()
							.addGap(43)
							.addComponent(s_author)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(s_authorTxt, GroupLayout.PREFERRED_SIZE, 156, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_bookSearchPanel.createSequentialGroup()
							.addGap(42)
							.addGroup(gl_bookSearchPanel.createParallelGroup(Alignment.TRAILING)
								.addComponent(cancelButton)
								.addComponent(s_status))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(s_notBorrowedJrb)
							.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
							.addComponent(s_borrowedJrb)))
					.addGap(455))
		);
		gl_bookSearchPanel.setVerticalGroup(
			gl_bookSearchPanel.createParallelGroup(Alignment.TRAILING)
				.addGroup(gl_bookSearchPanel.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_bookSearchPanel.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_bookSearchPanel.createSequentialGroup()
							.addGroup(gl_bookSearchPanel.createParallelGroup(Alignment.LEADING, false)
								.addComponent(s_bookName, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
								.addComponent(s_bookNameTxt, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE))
							.addGroup(gl_bookSearchPanel.createParallelGroup(Alignment.LEADING)
								.addGroup(gl_bookSearchPanel.createSequentialGroup()
									.addPreferredGap(ComponentPlacement.RELATED)
									.addGroup(gl_bookSearchPanel.createParallelGroup(Alignment.BASELINE)
										.addComponent(bookType)
										.addComponent(s_borrowedJrb)
										.addComponent(s_status)
										.addComponent(s_notBorrowedJrb)))
								.addGroup(gl_bookSearchPanel.createSequentialGroup()
									.addGap(16)
									.addComponent(s_bookTypeJcb, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
						.addGroup(gl_bookSearchPanel.createSequentialGroup()
							.addGroup(gl_bookSearchPanel.createParallelGroup(Alignment.BASELINE)
								.addComponent(s_authorTxt, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
								.addComponent(s_author, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
							.addGap(49)))
					.addGap(18)
					.addGroup(gl_bookSearchPanel.createParallelGroup(Alignment.LEADING)
						.addComponent(cancelButton)
						.addComponent(searchButton))
					.addGap(28))
		);
		bookSearchPanel.setLayout(gl_bookSearchPanel);
		getContentPane().setLayout(groupLayout);
		
		this.fillBookType();
		this.fillTable(new Book());
		
		//设置JFrame居中显示
		this.setLocation(40, 10);
	}

	
	
	/**
	 * 取消事件处理
	 * @param e
	 */
	protected void SearchReserValueActionPerformed(ActionEvent e) {
		this.s_bookNameTxt.setText("");
		this.s_authorTxt.setText("");
		if(this.s_bookTypeJcb.getItemCount()>0) {
			this.s_bookTypeJcb.setSelectedIndex(0);			
		}
		this.s_notBorrowedJrb.setSelected(true);
	}

	/**
	 * 图书信息查询事件处理
	 * @param e
	 */
	protected void bookSearchActionPerformed(ActionEvent e) {
		String bookName=this.s_bookNameTxt.getText();
		String author=this.s_authorTxt.getText();
		
		BookType bookType=(BookType) this.s_bookTypeJcb.getSelectedItem();
		int bookTypeId=bookType.getId();
		
		
		String status="";
		if(s_notBorrowedJrb.isSelected()) {
			status="在馆";
			
		}
		else if(s_borrowedJrb.isSelected()) {
			status="已借";
		}
		
		Book book=new Book(bookName,author,bookTypeId,status);
		this.fillTable(book);
		
		
	}
	
	/**
	 * 初始化表格数据
	 * @param book
	 */
	private void fillTable(Book book) {
		DefaultTableModel dtm=(DefaultTableModel) bookTable.getModel();
		dtm.setRowCount(0);//设置成0行
		Connection con=null;
		try {
			con=dbUtil.getCon();
			ResultSet rs=bookDao.list(con, book);
			while(rs.next()) {
				Vector v=new Vector();
				v.add(rs.getString("id"));
				v.add(rs.getString("bookName"));
				v.add(rs.getString("author"));
				v.add(rs.getString("sex"));
				v.add(rs.getFloat("price"));
				v.add(rs.getString("bookDesc"));
				v.add(rs.getString("bookTypeName"));
				v.add(rs.getString("status"));
				dtm.addRow(v);
			}
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			try {
				dbUtil.closeCon(con);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	

	/**
	 * 初始下拉框
	 * type 下拉框类型
	 */
	private void fillBookType() {
		Connection con=null;
		BookType bookType=null;
		try {
			con=dbUtil.getCon();
			ResultSet rs=bookTypeDao.list(con, new BookType());
		
				bookType=new BookType();
				bookType.setBookTypeName("请选择...");
				bookType.setId(-1);
				this.s_bookTypeJcb.addItem(bookType);
			
			while(rs.next()) {
				bookType=new BookType();
				bookType.setBookTypeName(rs.getString("bookTypeName"));
				bookType.setId(rs.getInt("id"));				
				this.s_bookTypeJcb.addItem(bookType);				
			}
			
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			try {
				dbUtil.closeCon(con);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	/**
	 * 表格行点击事件处理
	 * @param me
	 */
	private void bookTableMousePressed(MouseEvent met) {
		int row=this.bookTable.getSelectedRow();
		this.idTxt.setText((String)bookTable.getValueAt(row, 0));
		this.bookNameTxt.setText((String)bookTable.getValueAt(row, 1));
		this.authorTxt.setText((String)bookTable.getValueAt(row, 2));
		this.sexTxt.setText((String)bookTable.getValueAt(row, 3));
		this.priceTxt.setText((Float)bookTable.getValueAt(row, 4)+"");
		this.bookDescTxt.setText((String)bookTable.getValueAt(row, 5));
		this.bookTypeTxt.setText((String)bookTable.getValueAt(row, 6));
		this.statusTxt.setText((String)bookTable.getValueAt(row, 7));	
	}
	
	
	/**
	 * 重置表单
	 */
	private void reSetValue() {
		this.idTxt.setText("");
		this.bookNameTxt.setText("");
		this.authorTxt.setText("");
		this.priceTxt.setText("");
		this.s_notBorrowedJrb.setSelected(true);
		this.bookDescTxt.setText("");
		if(this.s_bookTypeJcb.getItemCount()>0) {
			this.s_bookTypeJcb.setSelectedIndex(0);
			
		}
	}
}
